Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding relative & absolute mip gaps #17

Merged
merged 13 commits into from
Nov 3, 2023

Conversation

zengjian-hu-rai
Copy link
Contributor

@zengjian-hu-rai zengjian-hu-rai commented Nov 1, 2023

https://relationalai.atlassian.net/jira/software/c/projects/RAI/boards/41?search=jian&selectedIssue=RAI-17621

Added supports for relative_gap_tolerance and absolute_gap_tolerance, and the report of final relative_gap from solver. Note that MOI doesn't support reporting the final absolute gap.

@@ -81,6 +81,8 @@ end
# solve and check output is expected for each input json file
@testset "$j" for j in json_names
output = JSON3.read(run_solve(read_json("inputs", j)))
@info output
#isdefined(Main, :Infiltrator) && Main.infiltrate(@__MODULE__, Base.@locals, @__FILE__, @__LINE__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the @info

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh my goodness. thought i 've removed them. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/SolverAPI.jl Outdated
@@ -111,6 +111,16 @@ function response(
res["solve_time_sec"] = Float64(MOI.get(model, MOI.SolveTimeSec()))

result_count = MOI.get(model, MOI.ResultCount())

try
res["relative_gap"] = Float64(MOI.get(model, MOI.RelativeGap()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes a little more sense to do

rel_gap = Float64(MOI.get(model, MOI.RelativeGap()))

and then only set res["relative_gap"] if it's finite.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. good point

res["relative_gap"] = Float64(MOI.get(model, MOI.RelativeGap()))
if isinf(res["relative_gap"])
res["relative_gap"] = nothing # Inf cannot be serialized to JSON
res["relative_gap"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line?

src/SolverAPI.jl Outdated
res["relative_gap"]
rel_gap = Float64(MOI.get(model, MOI.RelativeGap()))
if isinf(rel_gap)
res["relative_gap"] = rel_gap# Inf cannot be serialized to JSON
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
res["relative_gap"] = rel_gap# Inf cannot be serialized to JSON
res["relative_gap"] = rel_gap # Inf cannot be serialized to JSON

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, it should be if !isinf(rel_gap)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Co-authored-by: Chris Coey <[email protected]>
@chriscoey
Copy link
Member

nice! good to merge when green

@zengjian-hu-rai zengjian-hu-rai merged commit 7afbba5 into main Nov 3, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants